#ifndef _GAME_SYSTEM_MANAGER_H_
#define _GAME_SYSTEM_MANAGER_H_

#include "GameSystem.h"

#include "OgreSystem.h"
#include "InputHandler.h"
#include "GUISystem.h"
#include "WindowEventHandler.h"
#include "TerrainSystem.h"
#include "Physics.h"
#include "SkyGenerator.h"
#include "PagingSystem.h"
#include "XMLHandler.h"

class GameSystem;

class TerrainSystem;
class GUISystem;
class InputHandler;
class WindowEventHandler;
class OgreSystem;
class PhysicsSystem;
class PagingSystem;
class XMLHandler;

#include "Ogre.h"
using namespace Ogre;

typedef std::map<std::string,GameSystem*> GameSystemList;

class GameSystemManager {
public:
	GameSystemManager();
	~GameSystemManager();
	
	static GameSystemManager *getSingleton();
	
	void updateSystems();

	void registerSystem(GameSystem *sys);
	GameSystem* getSystem(std::string sys);

	void createOgre();
	static OgreSystem *getOgre();
	
	void createInput();
	static InputHandler* getInput();
	
	void createGUI();
	static GUISystem* getGUI();

	void createWindowHandler();
	static WindowEventHandler *getWindowHandler();

	void createTerrain();
	static TerrainSystem* getTerrain();
	
	void updateTimer();
	//Real getElapsedTime();

	void createPhysics();	
	static PhysicsSystem* getPhysics();

	void initSky();
	static SkyGenerator* getSky();

	void createPaging();
	static PagingSystem* getPaging();

	void createXMLHandler();
	static XMLHandler* getXMLHandler();

	

	Ogre::Real GameSystemManager::getTime();

	/*

	void startAllSystems();
	void createTerrain();
	
	void createGUI();
	void createNetwork();
	void createInput();

	static InputSystem* getInput();
	static myCEGUI* getGUI();
	static RakNetClient* getNetwork();
	*/
private:

	GameSystemList mGameSystemList;


	static OgreSystem* mOgre;
	static InputHandler* mInput;
	static GUISystem* mCEGUI;
	static WindowEventHandler* mWindowHandler;
	static TerrainSystem* mTerrain;
	static PhysicsSystem* mPhysics;
	static SkyGenerator* mSky;
	static PagingSystem* mPaging;
	
	static XMLHandler* mXML;

	//static RakNetClient* mRakNetClient;
	//static myNxPhysx* myPhysics;
	/*
	static SceneManager* mSceneMgr;
	static Camera* mCamera;
	static RenderWindow* mWindow;
	static Mouse*    mMouse;
	static Keyboard* mKeyboard;
	static GameState* mGameState;
	*/

	static Ogre::Timer timer;
	Real startTime,finishTime,elapsedTime;

	static GameSystemManager *mInstance;
	
};


#endif